﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL.Business;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!object.Equals(Session["adminName"], null))
        {
            Session["adminName"] = null;
        }
    }
    // 登陆
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            String userName = this.username.Text.ToString();
            String password = this.password.Text.ToString();
            bool IsSucess = false;
            BLL.Business.ManagerBLL manager = new BLL.Business.ManagerBLL();

            IsSucess = manager.LoginSucess(userName, password);
            if (IsSucess)
            {
                Session["adminName"] = userName;
                Response.Redirect("mainPage.aspx?adminUser=" + userName);
            }
            else
            {
                Response.Write("<script>alert('密码不正确或是用户名不存在！')</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message.ToString() + "')</script>");
        }
    }
}
